//
//  WCheckgoodsTopView.m
//  ProjectforHDX
//
//  Created by motom on 16/8/25.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "WCheckgoodsTopView.h"
#import "WCStroehouse.h"
@interface WCheckgoodsTopView()

@property (nonatomic, strong) RZCustomLable *count;
@property (nonatomic, strong) RZCustomLable *storeName;


@end

@implementation WCheckgoodsTopView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setupView];
    }
    return self;
}

-(void)setupView
{
   
    self.backgroundColor  = [UtilCheck hexStringToColor:@"#ffffff" alpha:1.0];
    
    RZCustomLable *count = [[RZCustomLable alloc]init];
    [count setFrame:CGRectMake(0, 0, 150, 20)];

    self.count = count;
    count.top =10;
    count.left = 10;
    [self addSubview:count];
    [self addSoldLine:1.0 soldcolor:[UtilCheck hexStringToColor:@"f0f0f0" alpha:1.0] Padding:0];
}

-(void)setPlateCount:(NSInteger)plateNumber
{
    NSString *headTitle = [UtilCheck language:@"delivery.scanTitle"];
    
    NSString *numberStr = [NSString stringWithFormat:@"%ld",(long)plateNumber];
   
    NSString *numberTitle = [NSString stringWithFormat:[UtilCheck language:@"delivery.scanTitle"],numberStr];
    
    NSMutableAttributedString *numberAttributedTitle = [[NSMutableAttributedString alloc] initWithString:numberTitle];
    NSRange range = [numberTitle rangeOfString:numberStr];
    [numberAttributedTitle addAttributes:@{NSForegroundColorAttributeName:[UtilCheck hexStringToColor:@"1a57be" alpha:1]} range:range];
    self.count.attributedText = numberAttributedTitle;
    self.count.font = CustomFont(14);
}


-(void)setStroeInfo:(WCStroehouse *)store
{
    
    if (store) {
        
        RZCustomLable *storeName = [[RZCustomLable alloc]init];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ :",[UtilCheck language:@"seeting.containNo"]] attributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
        
        if (store.name == nil) {
            return;
        }
        [str appendAttributedString:[[NSAttributedString alloc]initWithString:store.name attributes:@{NSForegroundColorAttributeName:[UIColor redColor]}]];
        storeName.attributedText = str;
        [storeName sizeToFit];
        storeName.right = SCREEN_WIDTH - 10;
        storeName.top = 10;
        storeName.font = CustomFont(14);
        if (self.storeName) {
            [self.storeName removeFromSuperview];
        }
        self.storeName = storeName;
        [self addSubview:self.storeName];
    }
}

@end
